package com.wuzheng.wisgo.sanitation.framework.base.config;

import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
import com.wuzheng.wisgo.sanitation.framework.base.mapper.CommonMapper;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author：hibon
 * @date：Created in 2019/08/20
 * @description：
 * @modified By：
 * @version: 1.0
 */
@Configuration
@MapperScan(basePackages = { "com.wuzheng.wisgo.**.mapper" })
public class MyBatisPlusConfig {
    private final  static Logger logger = LoggerFactory.getLogger(MyBatisPlusConfig.class);
    /**
     * mybatis-plus分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }

    @Bean
    public CommonMapper commonMapper(SqlSessionFactory sqlSessionFactory){
        logger.info("Init CommonMapper");
        return new CommonMapper(sqlSessionFactory);
    }
}
